//
// ColourTable
// =============
// A Cinema 4D command plugin, providing a color palette
// By Andreas Block, January 23th 2012
// Mail: open@andreasblock.de
//
// For further information, see colourtable.h
//
//------------------------------------------------------------------------
// File: manualkerning_defines.h  - declaration of defines and constants
//                                  (like e.g. default oparameters)
//

#ifndef _COLOURTABLE_DEFINES_H_
#define _COLOURTABLE_DEFINES_H_

// Debug
#define CTDEBUG
//#define CTDEBUG_GUI

// Defines
#define COLOURTABLE_VERSION_MAJOR        0x00
#define COLOURTABLE_VERSION_MINOR        0x00
#define COLOURTABLE_VERSION_BUILD        0x0001

#define COLOURTABLE_USER_COLORS_MAX      1000
#define COLOURTABLE_NUM_GROUPS           8

// DLG_OFFSETS - These are no actual IDs, but rather offsets on DLG_xxx bases IDs
// NOTE: THESE HAVE TO MATCH 
enum {
  OFFS_TDLG                       = 1,
  OFFS_GROUP_TAB                  = 2,
  OFFS_GROUP_TITLE                = 3,
  OFFS_SCROLLGROUP_CONTENT        = 4,
  OFFS_EDIT_SEARCH_NAME           = 5,
  OFFS_EDIT_SEARCH                = 6,
  OFFS_COLOR_FOUND                = 7,
  OFFS_COLOR_SCROLLGROUP          = 8,
  OFFS_BUTTON_ADD                 = 9,
  OFFS_BUTTON_DEL                 = 10,
  OFFS_BUTTON_ADD_NAME            = 11,
  OFFS_BUTTON_DEL_NAME            = 12,
  OFFS_SLIDER_PERCENT_NAME        = 13,
  OFFS_SLIDER_PERCENT             = 14,
  OFFS_SLIDER_NUM_COLORS_NAME     = 15,
  OFFS_SLIDER_NUM_COLORS          = 16,
  OFFS_COLOR_FOUND_NAME           = 17,
  OFFS_COLOR_BASE                 = 10000, // begin of color gadget IDs
  OFFS_STRING_BASE                = 20000, // begin of color name string IDs (actual IDs at bottom)
  OFFS_LABEL_BASE                 = 30000, // begin of static text gadget IDs
};

#define DLG_ID_SCROLLGROUP_CONTENT(idBase)     (idBase + OFFS_SCROLLGROUP_CONTENT)
#define DLG_ID_COLOR_BASE(idBase)              (idBase + OFFS_COLOR_BASE)
#define DLG_ID_LABEL_BASE(idBase)              (idBase + OFFS_LABEL_BASE)
#define DLG_ID_STRING_BASE(idBase)             (idBase + OFFS_STRING_BASE)
#define DLG_ID_EDIT_SEARCH(idBase)             (idBase + OFFS_EDIT_SEARCH)
#define DLG_ID_COLOR_FOUND(idBase)             (idBase + OFFS_COLOR_FOUND)
#define DLG_ID_SCROLLGROUP(idBase)             (idBase + OFFS_COLOR_SCROLLGROUP)
#define DLG_ID_BUTTON_ADD(idBase)              (idBase + OFFS_BUTTON_ADD)
#define DLG_ID_BUTTON_DEL(idBase)              (idBase + OFFS_BUTTON_DEL)
#define DLG_ID_BUTTON_ADD_NAME(idBase)         (idBase + OFFS_BUTTON_ADD_NAME)
#define DLG_ID_BUTTON_DEL_NAME(idBase)         (idBase + OFFS_BUTTON_DEL_NAME)
#define DLG_ID_SLIDER_PERCENT_NAME(idBase)     (idBase + OFFS_SLIDER_PERCENT_NAME)
#define DLG_ID_SLIDER_PERCENT(idBase)          (idBase + OFFS_SLIDER_PERCENT)
#define DLG_ID_SLIDER_NUM_COLORS_NAME(idBase)  (idBase + OFFS_SLIDER_NUM_COLORS_NAME)
#define DLG_ID_SLIDER_NUM_COLORS(idBase)       (idBase + OFFS_SLIDER_NUM_COLORS)
#define DLG_ID_COLOR_FOUND_NAME(idBase)        (idBase + OFFS_COLOR_FOUND_NAME)

#define COLOURTABLE_M_VIEW_GET_GROUP(id)        ((id >> 4) & 0x0000000F)
#define COLOURTABLE_M_VIEW_GET_FLAG(id)         (id & 0x0000000F)
#define COLOURTABLE_M_OPTIONS_GET_SUBMENU(id)   ((id >> 4) & 0x0000000F)
#define COLOURTABLE_M_OPTIONS_GET_PARAM(id)     (id & 0x0000000F)
#define COLOURTABLE_M_RESET_GET_GROUP(id)       (id & 0x0000000F)

enum {  // use with FlagDisplay...-methods
  DLG_FLAGS_DISPLAY_NONE       = 0x00000000,
  DLG_FLAGS_DISPLAY_NAME       = 0x00000001,
  DLG_FLAGS_DISPLAY_CODE       = 0x00000002,
  DLG_FLAGS_DISPLAY_VALUE      = 0x00000004,
  DLG_FLAGS_DISPLAY_ALL        = 0x00000007,
};

// IDs in Prefs subcontainer below 100000 (DLG_ bases)
enum {
  BC_L_FLAGS_GROUP         = 0,
  BC_L_NUM_COLUMNS         = 1, // layout columns
  BC_L_NUM_COLUMNS_ACTUAL  = 2,
  BC_L_NUM_ROWS            = 3, // layout rows
  BC_BC_WEIGHTS            = 4,
};
// IDs in Prefs and Doc subcontainer (actually these are offsets from DLG_xxx or g_iDlg)
// DLG_ bases are multiples of 100000
enum { // OFFSETS
  // Prefs container, only, equally available for all groups
  BC_OFFS_L_FLAGS_DISPLAY       = 0,
  BC_OFFS_L_NUM_COLUMNS_TEXT    = 1, // color columns
  BC_OFFS_L_NUM_COLUMNS_NOTEXT  = 2,
  // Prefs + Doc container, only available for certain groups
  BC_OFFS_L_NUM_COLORS       = 100,   // DLG_USER_DOC, DLG_USER_C4D, DLG_GREY
  BC_OFFS_R_GREY             = 101,   // DLG_GREY
  BC_OFFS_V_COLOR_BASE       = 10000, // DLG_USER_DOC, DLG_USER_C4D
  BC_OFFS_STR_NAME_BASE      = 20000, // DLG_USER_DOC, DLG_USER_C4D
};

#define DIV_CEIL(a, b) ((a % b) ? ((a / b) + 1) : (a / b))

// Parameter default values
#define COLORS_PER_ROW_NOTEXT            12
#define COLORS_PER_ROW_TEXT              4

#endif _COLOURTABLE_DEFINES_H_